package com.stwyj.sbd.config.exception;

import com.stwyj.sbd.common.AppErrors;

import java.io.Serializable;

/**
 *<p>
 * HttpStatus.OK 错误结果异常返回处理
 *</p>
 *
 * @author stwyj
 * @since 2018/11/29
 */
public class ResultErrorException extends Exception implements Serializable {

    private static final long serialVersionUID = -2285739833204427158L;

    public static final Integer DEFAULT_ERROR_CODE = 1000;
    public static final String DEFAULT_ERROR_MSG = "系统错误";

    private Integer code;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public ResultErrorException(Integer code, String message) {
        super(message, null);
        this.code = code;
    }

    public ResultErrorException(Integer code, String message, Throwable t) {
        super(message, t);
        this.code = code;
    }

    public ResultErrorException(Integer code) {
        super(AppErrors.message(code), null);
        this.code = code;
    }

    public ResultErrorException(Integer code, Throwable t) {
        super(AppErrors.message(code), t);
        this.code = code;
    }

    public ResultErrorException(AppErrors appErrors) {
        super(appErrors.message(), null);
        this.code = appErrors.code();
    }

    public ResultErrorException(AppErrors appErrors, Throwable t) {
        super(appErrors.message(), t);
        this.code = appErrors.code();
    }
}
